#include "networkmanager.h"
#include "../../../client/qt_messenger/network/netparam.h"
NetworkManager::NetworkManager(QObject *parent) :
    QObject(parent)
{
    if(NetParams::serverPort<=1023) return;
    server = new Server(NetParams::serverPort,this);
    connect(server,SIGNAL(notify(QString,int)),SIGNAL(notify(QString,int)));
    connect(server,SIGNAL(recieveData(QString,QByteArray)),SIGNAL(recieveData(QString,QByteArray)));
    connect(this,SIGNAL(recieveData(QString,QByteArray)),SLOT(onRecieveData(QString,QByteArray)));
}

void NetworkManager::onSendData(QString ip, QByteArray data)
{
    if(!server || ip.isEmpty() || data.isEmpty()) return;
    server->onSendData(ip,data);
}
void NetworkManager::onCloseConnection(QString ip)
{
    if(!server || ip.isEmpty()) return;
    server->onCloseConnection(ip);
}
void NetworkManager::onRecieveData(QString ip, QByteArray data)
{
    qDebug("in manager,come from %s",ip.toAscii().data());
}
